var path = this.path;
define(['dojo/_base/declare', 'geomap/plugins/layers/AnnoLayer'], function (declare, AnnoLayer) {
    var annoLayer = declare([AnnoLayer], {
        setData: function (mapView, layer) {
            var me = this;
            me.mapView = mapView;
            me.mapUtils = mapView.mapUtils;
            var options = layer.layer || {};
            me.props = options;
            var data = $.extend(true, [], options.data);
            if (!data || data.length < 1) {
                if (typeof options.callback == 'function') {
                    options.callback(layer);
                }
                return;
            }
            var lngLatArray = mapView.mapUtils.toLngLatArray(mapView, data, options);
            me.imageUrl = path + './../../one-map/1.0.0/src/mode/arcgis/css/images/square.svg';
            var spatialReference = null;
            if (options.sr) {
                spatialReference = me.spatialReference;
            }
            lngLatArray.map(function (lngLat, index) {
                if (lngLat.x > 0 && lngLat.y > 0) {
                    var point = mapView.mapUtils.createPoint(mapView, lngLat, {
                        sr: spatialReference,
                    });
                    var graphic = mapView.mapUtils.createGraphic(mapView, {
                        geometry: point,
                        attributes: lngLat,
                    });
                    me.add(graphic);
                }
            });
            me._initialize();
            if (typeof options.callback == 'function') {
                options.callback(layer);
            }
        },
        getGraphicLocation: function (mapView, esriEvent) {
            var geometry = esriEvent.graphic.geometry;
            var lngFieldName = mapView.getLngFieldName();
            var latFieldName = mapView.getLatFieldName();
            var location = {};
            location[lngFieldName] = geometry.x;
            location[latFieldName] = geometry.y;
            return location;
        },
    });
    return annoLayer;
});
